package com.example.l2p_feedback;

import java.util.Arrays;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TableRow.LayoutParams;
import android.widget.TextView;

public class View05_Recommender extends Activity {
	TableLayout table_layout;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view05_table);

		table_layout = (TableLayout) findViewById(R.id.tableLayout1);
		this.BuildTable(6, 3);
		this.setTitle("Complexity of Topics");
	}

	private void BuildTable(int rows, int cols) {

		List<String> topicsList = Arrays.asList("<b>Topics</b>",
				"Mobile Context", "Android Development", "Learner Modeling",
				"Data mining", "Recommendation System");
		List<String> verdictList = Arrays.asList("<b>Difficulty: ss12</b>",
				"Low", "High", "High", "Low", "Medium");
		List<String> verdictList2 = Arrays.asList("<b>Difficulty: ws14</b>",
				"Low", "Medium", "Medium", "Low", "High");

		// outer for loop
		for (int i = 1; i <= topicsList.size(); i++) {

			TableRow row = new TableRow(this);
			row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
					LayoutParams.WRAP_CONTENT));

			// inner for loop
			for (int j = 1; j <= cols; j++) {

				TextView tv = new TextView(this);
				tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
						LayoutParams.WRAP_CONTENT));
				// tv.setBackgroundResource(R.drawable.cell_shape);
				tv.setPadding(5, 5, 5, 5);
				// tv.setText("Topic " + i + ", Rating" + j);
				if (j == 1)
					tv.setText(Html.fromHtml(topicsList.get(i - 1)));
				else if (j == 2)
					tv.setText(Html.fromHtml(verdictList.get(i - 1)));
				else
					tv.setText(Html.fromHtml(verdictList2.get(i - 1)));

				row.addView(tv);

			}
			table_layout.addView(row);
		}
	}
}
